﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TeacherHelp.FormList.Student
{
    public partial class SheetForm : Form
    {
        protected override CreateParams CreateParams  //防止界面闪烁
        {
            get
            {
                CreateParams paras = base.CreateParams;
                paras.ExStyle |= 0x02000000;
                return paras;
            }
        }

        private readonly ExercisesInfoForm _exercisesInfoForm;

        private SheetForm()
        {
            InitializeComponent();
        }
        public SheetForm(ExercisesInfoForm exercisesInfoForm) : this()
        {
            _exercisesInfoForm = exercisesInfoForm;
        }

        private void CloseBtn_Click(object sender, EventArgs e)
        {
            var isExit = MessageBox.Show("确定要退出考试吗？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (isExit == DialogResult.OK)
                _exercisesInfoForm.Close();
        }

        private void JumpAnswer_Click(object sender, EventArgs e)
        {
            Control control = sender as Control;
            var name = control?.Name;
            if (name != null)
            {
                Regex regex = new Regex("[0-9]+");
                var index = regex.Match(name).Value;
                this.Hide();
                _exercisesInfoForm.curExercisesIndex = index.ToInt() - 1;
                _exercisesInfoForm.Show();
            }
        }

        private void submitBtn_Click(object sender, EventArgs e)
        {
            _exercisesInfoForm._startTestForm.SubmitDollors(true);
        }

    }
}
